package com.flowershop.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.flowershop.entity.CreativeProduct;
import com.flowershop.mapper.CreativeProductMapper;
import com.flowershop.service.CreativeProductService;

@Service
public class CreativeProductServiceImpl extends ServiceImpl<CreativeProductMapper, CreativeProduct> implements CreativeProductService {
    
    @Override
    @Transactional
    public boolean updateStock(Long id, Integer quantity) {
        CreativeProduct product = this.getById(id);
        if (product == null || product.getStock() < quantity) {
            return false;
        }
        
        product.setStock(product.getStock() - quantity);
        return this.updateById(product);
    }
} 